<template>
  <div><el-container>
  <el-header>用户注册</el-header>
  <el-main><el-form
      :model="ruleForm"
      ref="ruleForm"
      label-width="100px"
      class="demo-ruleForm"
    >
      <el-form-item label="用户名" prop="username">
        <el-input v-model="ruleForm.username"></el-input>
      </el-form-item>
      <el-form-item label="密码"   prop="password">
        <el-input type="password"  v-model="ruleForm.password"></el-input>
      </el-form-item>
      <el-form-item label="qq号"   prop="qq">
        <el-input type="text"  v-model="ruleForm.qq"></el-input>
      </el-form-item>
      
        <el-button type="primary" @click="submitForm(ruleForm)"
          >立即注册</el-button
        >
        <el-button @click="resetForm('ruleForm')">重置</el-button>
      
    </el-form></el-main>
  <el-footer>powerBy Edwin</el-footer>
</el-container></div>
</template>

<script>
import UserApi from '@/api/UserApi';
export default {
    data() {
    return {
      ruleForm: {
        username:"",
        password:"",
        qq:""     
      }
    };
  },

    mounted(){
    
            console.log(123);
   
    },methods:{
        submitForm(ruleForm) {
         
           UserApi.register(ruleForm).then(result=>{ 
          if(result.code ==200){
            alert("注册成功")
            
            this.$router.push("/login")
          }else{
            alert(result.msg)
          }
           })
          
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    }

}
</script>

<style>
.el-header, .el-footer {
    background-color: #B3C0D1;
    color: #333;
    text-align: center;
    line-height: 60px;
  }
  .el-main {
    background-color: #E9EEF3;
    color: #333;
    text-align: center;
    line-height: 160px;
  }
</style>